package com.gunncs.actoriface;
import com.gunncs.actoriface.*;
public class LeftActor implements Actor {
	int step = 0;
	int nsteps = 2;
	boolean trouble=false;

        public String getMaze() {
          return "DecisionTesters";
        }
	
	public void act(Robot r) {
		if(trouble){
			r.goBackward();
			r.waitDistance(10 +(int)(Math.random() * 10));

			if(Math.random() > .5)
			  r.turnLeft();
			else
			  r.turnRight();
			r.waitAngle(90);
			
			//Turns right 90 degrees
		} else {
			r.goForward();
			r.waitDistance(1);
		}
	

	}

	public void updateSensors(Sensor[] sensors) {
		if(sensors[0].getState()[0] == TouchSensor.PRESSED){
			trouble = true;
			Simulator.out.println("hit!");
		} else {
		  trouble = false;
		}
		if(sensors[5].getState()[0] != 0){
		  System.out.println(sensors[5].getState()[0]);
		}

	}
}